package com.xinqi.modules.course.clazz.client;

import com.xinqi.common.base.constants.ServiceNameConstants;
import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.common.core.enums.ClassRoleEnum;
import com.xinqi.modules.course.clazz.dto.req.ClassStudentQueryDTO;
import com.xinqi.modules.course.clazz.dto.rsp.ClassStudentResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 班级学生表客户端
 *
 * @author: system
 * @date: 2023/10/31
 */
@FeignClient(contextId = "classStudentClient", value = ServiceNameConstants.XQ_COURSE)
public interface ClassStudentClient {
    String INNER_PREFIX = "/inner/class-student";

    /**
     * 班级学生表-分页
     */
    @GetMapping(INNER_PREFIX + "/page")
    R<PageInfo<ClassStudentResultDTO>> page(ClassStudentQueryDTO dto);

    /**
     * 班级学生-详情
     */
    @GetMapping(INNER_PREFIX + "/{id}")
    R<ClassStudentResultDTO> findById(@PathVariable("id") Long id);

    /**
     * 班级成员-权限校验
     */
    @GetMapping(INNER_PREFIX + "/checkIsStudent/{classId}/{userId}")
    R<Boolean> checkIsStudent(@PathVariable("classId") Long classId, @PathVariable("userId") Long userId);

    /**
     * 班级学生-列表
     */
    @GetMapping(INNER_PREFIX + "/studentListByClassId/{classId}")
    R<List<ClassStudentResultDTO>> studentListByClassId(@PathVariable("classId") Long classId);

    /**
     * 班级全部成员-列表
     */
    @GetMapping(INNER_PREFIX + "/allUserListByClassId/{classId}")
    R<List<ClassStudentResultDTO>> allUserListByClassId(@PathVariable("classId") Long classId);

    /**
     * 通过角色-查询班级成员-列表
     */
    @GetMapping(INNER_PREFIX + "/findByClassIdListAndRoleList/")
    R<List<ClassStudentResultDTO>> findByClassIdListAndRoleList(@RequestParam("classIdList") List<Long> classIdList, @RequestParam("roles") List<ClassRoleEnum> roles);

    /**
     * 通过班级ID和用户ID
     * 查询学生信息
     */
    @GetMapping(INNER_PREFIX + "/findByStudentId/{classId}/{userId}")
    R<ClassStudentResultDTO> findByStudentId(@PathVariable("classId") Long classId, @PathVariable("userId") Long userId);

    /**
     * 通过班级ID和用户ID结合
     * 查询学生信息
     */
    @GetMapping(INNER_PREFIX + "/findByStudentIds/{classId}")
    R<List<ClassStudentResultDTO>> findByStudentIds(@PathVariable("classId") Long classId, @RequestParam("userIds") List<Long> userIds);

    /**
     * 校验用户权限
     */
    @GetMapping(INNER_PREFIX + "/checkRole/{classId}/{userId}")
    R<ClassStudentResultDTO> checkRole(@PathVariable("classId") Long classId, @PathVariable("userId") Long userId, @RequestParam("classRoles") List<ClassRoleEnum> classRoles);

    @GetMapping(INNER_PREFIX + "/findContainsTeacherListByClassId/{classId}")
    R<List<ClassStudentResultDTO>> findContainsTeacherListByClassId(@PathVariable("classId") Long classId);

    @GetMapping(INNER_PREFIX + "/find-all-roles-student/{classId}/{studentId}")
    R<ClassStudentResultDTO> findAllRolesStudentByClassIdAndStudentId(@PathVariable("classId") Long classId, @PathVariable("studentId") Long studentId);

    /**
     * 根据班级id和用户id查询模拟用户
     *
     * @param classId 班级id
     * @param userId  用户id
     * @return 模拟学生id
     */
    @GetMapping(INNER_PREFIX + "/find-virtual-class-student/{classId}/{userId}")
    R<ClassStudentResultDTO> findVirtualClassStudentByClassIdAndUserId(@PathVariable("classId") Long classId, @PathVariable("userId") Long userId);

    /**
     * 根据班级id查询班级总学生(只统计模拟主学生)
     *
     * @param classId 班级id
     * @return 模拟学生id
     */
    @GetMapping(INNER_PREFIX + "/find-class-master-student-list")
    R<List<ClassStudentResultDTO>> findClassMasterStudentByClassId(@RequestParam("classId") Long classId);


    /**
     * 根据班级id列表查询班级总学生(只统计模拟主学生)
     *
     * @param classIdList 班级id集合
     * @return 模拟学生id
     */
    @PostMapping(INNER_PREFIX + "/find-class-master-student-list-by-classIds")
    R<List<ClassStudentResultDTO>> findClassMasterStudentByClassIdList(@RequestBody List<Long> classIdList);

    /**
     * 根据班级id和主学生ID集合查询班级学生(只统计关系学生)
     *
     * @param studentIds 主学生ID集合
     * @return 模拟学生id
     */
    @PostMapping(INNER_PREFIX + "/find-class-relationship-student-list/{classId}")
    R<List<ClassStudentResultDTO>> findClassRelationshipStudentList(@PathVariable("classId") Long classId, @RequestBody List<Long> studentIds);

}
